Skip to content

Minor issue fixes#13627

Merged
KarnaiahPesula merged 1 commit into
developmentfrom
feature-13602-giardiasis-case-based-surveillance
Oct 16, 2025
Merged

Minor issue fixes#13627
KarnaiahPesula merged 1 commit into
developmentfrom
feature-13602-giardiasis-case-based-surveillance

Conversation

@KarnaiahPesula
Copy link
Copy Markdown
Contributor

@KarnaiahPesula KarnaiahPesula commented Oct 15, 2025

Fixes #

Summary by CodeRabbit

  • New Features

    • Added “Imported case” flag and “Country of contamination” to epidemiological data.
    • Country selection uses an active country list for easy picking.
  • UI

    • New fields appear in the EpiData form with conditional visibility (country shown when “Imported case” is set accordingly).
    • Minor layout adjustments for clarity.
  • Localization

    • Added captions for the new fields to support translations.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Oct 15, 2025

Walkthrough

Adds importedCase and country fields to epidemiological data across API, backend entity/facade, UI form, i18n captions, and SQL schema. Updates DTO annotations, ORM mappings, facade mapping, UI visibility and inputs, and resources. Extends schema with new columns and adds related exposure columns and symptom type adjustments.

Changes

Cohort / File(s) Summary
API DTO updates
sormas-api/src/main/java/de/symeda/sormas/api/epidata/EpiDataDto.java
Added fields: importedCase (YesNoUnknown) and country (CountryReferenceDto); getters/setters; constants; adjusted @diseases annotations.
i18n keys
sormas-api/src/main/java/de/symeda/sormas/api/i18n/Captions.java, sormas-api/src/main/resources/captions.properties
Introduced EpiData_importedCase and EpiData_country keys; added corresponding captions.
Backend entity and mapping
sormas-backend/src/main/java/de/symeda/sormas/backend/epidata/EpiData.java, sormas-backend/src/main/java/de/symeda/sormas/backend/epidata/EpiDataFacadeEjb.java
EpiData entity: new fields with @Enumerated and @manytoone Country; facade maps importedCase and country; injects CountryService to resolve Country.
Database schema
sormas-backend/src/main/resources/sql/sormas_schema.sql
Added epidata/importedCase and epidata/country_id (and history); added several exposure columns; changed Symptoms weightlossamount to float4.
UI form
sormas-ui/src/main/java/de/symeda/sormas/ui/epidata/EpiDataForm.java
Added IMPORTED_CASE and COUNTRY fields; populated country ComboBox from references; visibility rules linking importedCase and country; minor variable rename for cluster type field.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant U as User
  participant UI as EpiDataForm (UI)
  participant F as EpiDataFacadeEjb
  participant CS as CountryService
  participant DB as Database

  U->>UI: Set Imported Case / Country
  UI->>F: save(EpiDataDto{importedCase, countryRef})
  activate F
  F->>CS: findByUuid(countryRef.uuid)
  CS-->>F: Country entity
  F->>DB: Persist EpiData{importedCase, country_id}
  DB-->>F: OK
  F-->>UI: Saved DTO
  deactivate F

  Note over UI,F: On load/edit
  UI->>F: getByCase(...)
  F->>DB: Fetch EpiData + Country
  DB-->>F: Entity
  F-->>UI: EpiDataDto{importedCase, countryRef}
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested reviewers

  • raulbob
  • obinna-h-n

Poem

A rabbit taps keys with a gentle thrum,
New fields hop in—imported, where from?
Countries line up in a tidy row,
DTOs whisper, “Map and go.”
Schema burrows deeper, UI shows face—
Hippity-hop, we’ve traced the case! 🐇✨

Pre-merge checks and finishing touches

❌ Failed checks (3 warnings)
Check name Status Explanation Resolution
Title Check ⚠️ Warning The title “Minor issue fixes” is overly generic and does not reflect the substantive additions of importedCase and country fields across the API, backend, database schema, and UI for giardiasis case‐based surveillance. Rename the title to clearly summarize the primary change, for example “Add importedCase and country fields to EpiData for giardiasis surveillance,” so that reviewers immediately understand the scope of the update.
Description Check ⚠️ Warning The pull request description only includes the unused template comments and “Fixes #” without any issue number or summary of changes, so it fails to document what this PR actually does or which issue it addresses. Complete the description by specifying the related issue number and providing a concise summary of the added importedCase and country fields across the API, backend, database schema, and UI, following the repository’s template structure.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feature-13602-giardiasis-case-based-surveillance

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (1)
sormas-ui/src/main/java/de/symeda/sormas/ui/epidata/EpiDataForm.java (1)

175-179: Respect visibility checkers when toggling COUNTRY; prefer setVisibleWithCheckersWhen.

Current setVisibleWhen can re-show fields disallowed by FieldVisibilityCheckers after user interaction. Use the checker-aware helper.

- FieldHelper.setVisibleWhen(getFieldGroup(), EpiDataDto.COUNTRY, EpiDataDto.IMPORTED_CASE, YesNoUnknown.YES, true);
+ FieldHelper.setVisibleWithCheckersWhen(
+   getFieldGroup(),
+   EpiDataDto.COUNTRY,
+   EpiDataDto.IMPORTED_CASE,
+   YesNoUnknown.YES,
+   getFieldVisibilityCheckers(),
+   true);

Optionally, make COUNTRY required when IMPORTED_CASE == YES for better data quality.

Also applies to: 193-193

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4852720 and d8d397c.

📒 Files selected for processing (7)
  • sormas-api/src/main/java/de/symeda/sormas/api/epidata/EpiDataDto.java (4 hunks)
  • sormas-api/src/main/java/de/symeda/sormas/api/i18n/Captions.java (1 hunks)
  • sormas-api/src/main/resources/captions.properties (1 hunks)
  • sormas-backend/src/main/java/de/symeda/sormas/backend/epidata/EpiData.java (5 hunks)
  • sormas-backend/src/main/java/de/symeda/sormas/backend/epidata/EpiDataFacadeEjb.java (4 hunks)
  • sormas-backend/src/main/resources/sql/sormas_schema.sql (4 hunks)
  • sormas-ui/src/main/java/de/symeda/sormas/ui/epidata/EpiDataForm.java (5 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
sormas-ui/src/main/java/de/symeda/sormas/ui/epidata/EpiDataForm.java (2)
sormas-api/src/main/java/de/symeda/sormas/api/FacadeProvider.java (1)
  • FacadeProvider (127-594)
sormas-ui/src/main/java/de/symeda/sormas/ui/utils/FieldHelper.java (1)
  • FieldHelper (56-1270)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: android app test (26)
  • GitHub Check: android app test (27)
  • GitHub Check: android app test (28)
  • GitHub Check: SORMAS CI
🔇 Additional comments (8)
sormas-api/src/main/resources/captions.properties (1)

1156-1157: LGTM! Caption additions are clear and well-placed.

The new i18n keys for EpiData.importedCase and EpiData.country are properly formatted and provide clear descriptive text that aligns with the new fields added to the epidemiological data model for GIARDIASIS disease surveillance.

sormas-api/src/main/java/de/symeda/sormas/api/epidata/EpiDataDto.java (1)

35-35: LGTM! New fields are properly implemented.

The additions of importedCase and country fields are well-structured:

  • Appropriate imports added (line 35)
  • Public constants defined for field names (lines 69-70)
  • Fields correctly annotated with @Diseases({Disease.GIARDIASIS}) (lines 81-83, 133-135)
  • Standard getters and setters implemented (lines 280-294)
  • Types are appropriate: YesNoUnknown for boolean-like state and CountryReferenceDto for country reference

The clone() method doesn't require updates since both new fields are simple types that don't need deep cloning.

Also applies to: 69-70, 81-83, 133-135, 280-294

sormas-backend/src/main/java/de/symeda/sormas/backend/epidata/EpiData.java (1)

29-30: LGTM! Entity mappings follow JPA best practices.

The new fields are properly implemented:

  • importedCase (line 62) uses @Enumerated(EnumType.STRING) for database-friendly enum storage (lines 233-236)
  • country (line 74) uses @ManyToOne(fetch = FetchType.LAZY) for efficient reference loading (lines 242-245)
  • All necessary imports added (lines 29-30, 42)
  • Standard getters and setters follow convention (lines 237-240, 247-249)

The lazy loading strategy for the country relationship is appropriate as it avoids unnecessary database joins when the country information is not needed.

Also applies to: 42-42, 62-62, 74-74, 233-249

sormas-backend/src/main/java/de/symeda/sormas/backend/epidata/EpiDataFacadeEjb.java (3)

42-44: Country facade/service imports are correct.


63-65: EJB injection of CountryService is fine.


115-117: Null-safety for country mapping; please confirm helpers handle nulls.

If source.getCountry() is null, ensure countryService.getByReferenceDto and CountryFacadeEjb.toReferenceDto return null safely to avoid NPEs. If not guaranteed, guard the calls.

Also applies to: 281-283

sormas-ui/src/main/java/de/symeda/sormas/ui/epidata/EpiDataForm.java (1)

85-85: Layout row for IMPORTED_CASE + COUNTRY — LGTM.

sormas-api/src/main/java/de/symeda/sormas/api/i18n/Captions.java (1)

1569-1574: New EpiData caption keys verified
captions.properties lines 1156–1157 contain EpiData.importedCase and EpiData.country.

Comment on lines 77 to 79
@Diseases({
Disease.MEASLES,
Disease.GIARDIASIS })
Disease.MEASLES })
private CaseImportedStatus caseImportedStatus;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

Verify the removal of GIARDIASIS from caseImportedStatus.

The @Diseases annotation on caseImportedStatus now only includes Disease.MEASLES, with Disease.GIARDIASIS removed. This change aligns with the introduction of the new importedCase field for GIARDIASIS (lines 81-83). However, if existing GIARDIASIS cases previously used caseImportedStatus, this could be a breaking change.

Please confirm:

  1. Are there existing GIARDIASIS cases in production that use caseImportedStatus?
  2. If yes, is there a data migration strategy to move this data to the new importedCase field?
  3. Should the database schema changes include a migration script to handle this transition?

You can verify existing usage with:


🏁 Script executed:

#!/bin/bash
# Search for GIARDIASIS and caseImportedStatus usage together in the codebase
rg -n --type=java -C3 'caseImportedStatus' | grep -i giardiasis

# Check if there are any database migration scripts for this change
fd -e sql -e xml | xargs rg -l 'caseImportedStatus\|importedCase' | head -20

Length of output: 96


Remove stale GIARDIASIS entry and add migration

  • EpiDataDto.java (lines 77–83): @Diseases still includes Disease.GIARDIASIS—remove it to match intended MEASLES-only usage.
  • No SQL/XML migration found for moving existing GIARDIASIS data to the new importedCase field—add a DB migration script to preserve and transfer that data.
🤖 Prompt for AI Agents
In sormas-api/src/main/java/de/symeda/sormas/api/epidata/EpiDataDto.java around
lines 77 to 79, remove the stale Disease.GIARDIASIS entry from the @Diseases
annotation so it only lists Disease.MEASLES, and create a DB migration (SQL or
XML Flyway/Liquibase script) that finds rows still marked with GIARDIASIS in the
old field, maps those values to the new importedCase field for the corresponding
records, and clears or deprecates the old field; ensure the migration is
idempotent, covers all affected tables/columns, includes a short descriptive
versioned filename and test/verification steps in the migration comment.

Comment on lines +14685 to +14686
alter table epidata add column if not exists importedCase varchar(255);
alter table epidata add column if not exists country_id bigint;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

Don’t re-create an existing FK with IF NOT EXISTS.

epidata_country_id_fk already exists in deployed databases. Re-running this script now tries to add the same foreign key again and Postgres errors because ALTER TABLE … ADD CONSTRAINT … IF NOT EXISTS isn’t supported. Drop-and-recreate or wrap the new constraint in a migration that first checks pg_constraint; otherwise the migration blocks releases.

🤖 Prompt for AI Agents
sormas-backend/src/main/resources/sql/sormas_schema.sql around lines
14685-14686: the migration blindly recreates the epidata_country_id_fk foreign
key which already exists and Postgres does not support ALTER TABLE ... ADD
CONSTRAINT IF NOT EXISTS; change the migration so it does not attempt to add the
FK unconditionally — either write a proper migration that first checks
pg_constraint (select to see if epidata_country_id_fk exists) and only issues
the ALTER TABLE ... ADD CONSTRAINT when absent, or perform a safe
drop-and-recreate: in a transactional migration drop the existing
epidata_country_id_fk if present and then add the new constraint; ensure the
check/drop logic runs in SQL (or the project’s migration framework) so
re-applying the script won’t error and will not block releases.

@KarnaiahPesula KarnaiahPesula merged commit 5f89986 into development Oct 16, 2025
5 of 13 checks passed
@KarnaiahPesula KarnaiahPesula deleted the feature-13602-giardiasis-case-based-surveillance branch October 16, 2025 08:50
@coderabbitai coderabbitai Bot mentioned this pull request Nov 14, 2025
@coderabbitai coderabbitai Bot mentioned this pull request Apr 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants